Function Pop-Up:

The first goal in editing is to get all the routines to show up in the "Function Pop-Up" menu.  This is so you will know you’ve got whole routines to End Of File, and also for faster navigation.  If you don’t do this first, they will just be extra compiler errors later.

For all routines to so appear in the popup, there must be an equal number of start and end braces, and no “nested functions.”

CTools™ only converts the “var” and first “begin” in place.  It eats “var” and changes “begin” into a begining brace.  Since Pascal is “backward”, these begining braces are in the wrong place - after the variables.  This is relatively easy to remedy.

Find:

)<CR>   // (right paren, return)

and replace with:

)<CR>  // (right paren, return, left brace)

Do this manually using Command G and/or Command H, so you can SEE what you are changing.  Automatic ("Replace All") will create the need for extra editing by doing it to ALL routines!  You don’t want to do it to routines - only prototypes.

Before dealing with the, now, extra brace, you MUST replace the:

;

with:

You can use the Replace All command for this one.  This is done to prevent interference with the next two editing steps without eating your start braces on nested functions.

Still cleaning up the extra start braces, you’ll find two situations:
(1) The extra begin brace is after a line ending in a comment.
(2) The extra begin brace is after a line ending in ‘;’.

In either case, there may be one or more carriage returns, then one or more TABs, before the brace.  If there’s one RETURN and one TAB, Find:

;
        // (semicolon, return, tab, left brace)

and replace with:

;
       // (semicolon, return)

You may have to add TABs and RETURNs as needed, depending on the variety of indents and returns carried over from the Pascal.

On this last one, the only thing that will prevent you from getting them all is a comment after the ';' in the first line.  To find these, use the Function Pop Up.  The extra brace will be in the bottom one on the list or in the routine just below it.